Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / the jucer / src / ui / jucer_PaintRoutinePanel.cpp
blob8abe8c0fddb3e238441a6281c939329d8f880989
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_PaintRoutinePanel.h"
28 #include "../properties/jucer_ColourPropertyComponent.h"
29 #include "../model/paintelements/jucer_PaintElementPath.h"
32 //==============================================================================
33 class ComponentBackgroundColourProperty : public ColourPropertyComponent,
34 private ChangeListener
36 public:
37 ComponentBackgroundColourProperty (JucerDocument& document_,
38 PaintRoutine& routine_)
39 : ColourPropertyComponent ("background", false),
40 document (document_),
41 routine (routine_)
43 document.addChangeListener (this);
46 ~ComponentBackgroundColourProperty()
48 document.removeChangeListener (this);
51 void changeListenerCallback (ChangeBroadcaster*)
53 refresh();
56 void setColour (const Colour& newColour) { routine.setBackgroundColour (newColour); }
57 const Colour getColour() const { return routine.getBackgroundColour(); }
59 void resetToDefault()
61 jassertfalse // option shouldn't be visible
64 protected:
65 JucerDocument& document;
66 PaintRoutine& routine;
70 //==============================================================================
71 class GraphicsPropsPanel : public Component,
72 public ChangeListener
74 public:
75 //==============================================================================
76 GraphicsPropsPanel (PaintRoutine& paintRoutine_,
77 JucerDocument* document_)
78 : paintRoutine (paintRoutine_),
79 document (document_)
81 paintRoutine.getSelectedElements().addChangeListener (this);
82 paintRoutine.getSelectedPoints().addChangeListener (this);
84 addAndMakeVisible (propsPanel = new PropertyPanel());
87 ~GraphicsPropsPanel()
89 paintRoutine.getSelectedPoints().removeChangeListener (this);
90 paintRoutine.getSelectedElements().removeChangeListener (this);
92 clear();
93 deleteAllChildren();
96 //==============================================================================
97 void resized()
99 propsPanel->setBounds (4, 4, getWidth() - 8, getHeight() - 8);
102 void changeListenerCallback (ChangeBroadcaster*)
104 updateList();
107 void clear()
109 propsPanel->clear();
112 void updateList()
114 XmlElement* const state = propsPanel->getOpennessState();
116 clear();
118 if (document != 0)
120 Array <PropertyComponent*> props;
121 props.add (new ComponentBackgroundColourProperty (*document, paintRoutine));
123 propsPanel->addSection ("Class Properties", props);
126 if (state != 0)
128 propsPanel->restoreOpennessState (*state);
129 delete state;
132 if (paintRoutine.getSelectedElements().getNumSelected() == 1) // xxx need to cope with multiple
134 PaintElement* const pe = paintRoutine.getSelectedElements().getSelectedItem (0);
136 if (pe != 0)
138 Array <PropertyComponent*> props;
139 pe->getEditableProperties (props);
141 propsPanel->addSection (pe->getTypeName(), props);
145 if (paintRoutine.getSelectedPoints().getNumSelected() == 1) // xxx need to cope with multiple
147 PathPoint* const point = paintRoutine.getSelectedPoints().getSelectedItem (0);
149 if (point != 0)
151 Array <PropertyComponent*> props;
152 point->getEditableProperties (props);
154 propsPanel->addSection ("Path segment", props);
159 private:
160 PaintRoutine& paintRoutine;
161 JucerDocument* document;
163 PropertyPanel* propsPanel;
167 //==============================================================================
168 PaintRoutinePanel::PaintRoutinePanel (JucerDocument& document_,
169 PaintRoutine& routine_,
170 JucerDocumentHolder* documentHolder)
171 : EditingPanelBase (document_,
172 new GraphicsPropsPanel (routine_, &document_),
173 new PaintRoutineEditor (routine_, document_, documentHolder)),
174 routine (routine_)
178 PaintRoutinePanel::~PaintRoutinePanel()
180 deleteAllChildren();
183 void PaintRoutinePanel::updatePropertiesList()
185 ((GraphicsPropsPanel*) propsPanel)->updateList();
188 const Rectangle<int> PaintRoutinePanel::getComponentArea() const
190 return ((PaintRoutineEditor*) editor)->getComponentArea();